<!--
    page description : 근태관리 - 입력자 - 근태등록 화면 - 퇴근입력 (pop_up)
    author      : Yang D
    date        : 2009-01-19
    file name   : attend_close_p.jsp
-->

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<s:head theme="ajax" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="/inc/css/common.css" />
<link rel="stylesheet" type="text/css" href="style/style.css" />
<script type="text/javascript" src="/inc/js/common.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script src="inc/js/common.js"></script>
<title>퇴근정보 입력</title>
<script type="text/javascript" language="javascript">
	
	// --------------------J A V A S C R I P T-START-------------------- //
		function fnc_submit(f) {
			
			//퇴근지
			var slIdx 	=	f.check_in_place.selectedIndex;
			var opt		=	f.check_in_place.options[slIdx];
            var i=0;
            var len=f.etc_emp.value.length;
            var temp=f.etc_emp.value;
            var cnt=0;            
			var check_type = f.check_in_type.value; 	// 퇴근 유형 변수 2011.09.06 추가
			var check_place = f.check_in_place.value;	// 퇴근지 변수2011.09.06 추가
			
			//직접입력
			if ( ((f.check_in_type.value == "1002" || f.check_in_type.value == "1007") && f.etc_emp.value == "") || (opt.value == "3999"  && f.etc_emp.value == "")) {
				alert("<s:text name="alert.message.emptyEtc" />");
				f.etc_emp.focus();
				return false;
			}
			
			if( f.check_in_type.value == "1002"  || f.check_in_type.value == "1007"  || opt.value == "3999"){                
                for(i=0;i<len;i++){                	
	                 if(temp.charAt(i)==" "){
	                      cnt++;
	                 }

            	} 
            	if(len==cnt){
					alert("비고란에 공백을 허용하지 않습니다.");
					f.etc_emp.focus();
					return false;
	   		 	}              
        	}
			
			/*
			* 2011.09.06
			* 최병옥
			* 퇴근유형과 퇴근지가 공백이나 null 값이 들어 입력 되는걸 방지
			*/
						
			if(checkField(check_type) == false){
				alert("퇴근유형을 확인해주세요.");
				return false;
			} else if(checkField(check_place) == false ){
				alert("퇴근지를 확인해주세요.");
				return false;
			} else {
				if (confirm("퇴근유형 :  " + f.check_in_type.options[f.check_in_type.selectedIndex].text + "\n\n퇴근지    :  " + opt.text+"\n\n비고       :  " + f.etc_emp.value + "   \n\n\n입력하신 퇴근정보입니다. \n\n확인을 클릭하시면 저장됩니다.")) {
					f.action = "update_emp_check_out.action";		//퇴근근등록
				} else {			
					alert("취소되었습니다.");				
					return false;
				}				
			}
			
		}
	
			
		//출근정보 저장시
		// ajax를 적용하여 opener의 죄회 데이터를 바로 적용함.
		
	    function fnc_apply_change() {

	        var rtn_msg = document.getElementById("msg").value;
	        
	        if(rtn_msg.length != 0) {
	            alert(rtn_msg);
	            window.close();
	            opener.call_dojo();
	        }
	        
	    }

		//
	    function  fnc_check_type(se) {
	    	//퇴근유형
			var sIdx	=	se.selectedindex;
			var optInx	=	se.options[sIdx];

			//현지퇴근
			if (se.value == "0003") {
				
				for ( var i = 0; i < frm_check_in.check_in_place.length; i++) {
					if (frm_check_in.check_in_place.options[i].value == "3999") {
						frm_check_in.check_in_place.options[i].selected = true;
					}
				}
			}
	    }

	    function fnc_check_type(se) {
	    	//출근유형
			var sIdx	=	se.selectedindex;
			var optInx	=	se.options[sIdx];

			//현지출근
			if (se.value == "1002") {
				
				for ( var i = 0; i < frm_check_out.check_in_place.length; i++) {
					if (frm_check_out.check_in_place.options[i].value == "3999") {
						frm_check_out.check_in_place.options[i].selected = true;
					}
				}
			}
		}

	//-- --------------------J A V A S C R I P T-E N D-------------------- //
	</script>
</head>
<body onload="fnc_apply_change()">
	<s:form name="frm_check_out" id="frm_check_out" method="post"
		theme="simple" onsubmit="return fnc_submit(this)">
		<s:hidden name="yyyymmdd" />
		<!-- 기준일자 -->
		<s:hidden name="check_in_time" />
		<!-- 출근시간 표시 -->
		<s:hidden name="msg" />
		<!-- 저장 메시지 출력 -->
		<s:hidden name="emp_no" />
		<!-- 저장 메시지 출력 -->

		<input type="hidden" name="ip" id="ip"
			value="<%=request.getRemoteAddr() %>" />

		<div id="popup_350se_top"></div>
		<div id="popup_350se_bg">
			<div id="popup_325se">
				<div id="popup_325se_box">
					<ul>
						<li class="txt">기준일자</li>
						<li><s:property value="yyyy_mm_dd" />
						</li>
					</ul>
					<ul>
						<li class="txt">퇴근일자</li>
						<li><s:property value="check_out_yyymmdd" />
						</li>
					</ul>
					<ul>
						<li class="txt">퇴근유형</li>
						<li><s:select name="check_in_type" id="check_in_type"
								cssClass="combobox120se" list="listCheckOutType" listKey="cd"
								listValue="cd_nm" onchange="fnc_check_type(this)" />
						</li>
					</ul>
					<ul>
						<li class="txt">퇴근지</li>
						<li><s:select name="check_in_place" id="check_in_place"
								cssClass="combobox120se" list="listCheckInPLace" listKey="cd"
								listValue="cd_nm" />
						</li>
					</ul>
					<ul>
						<li class="txt">비고</li>
						<li><s:textfield cssClass="input_200se" maxlength="16"
								name="etc_emp" value="%{msg_etc_emp}" />
						</li>
					</ul>
					<div id="popup_btn">
						<input type="image" value="저장" src="/images/btn_save.gif"
							style="cursor: pointer;" alt="퇴근저장" title="퇴근저장" />
					</div>
				</div>
			</div>
		</div>
		<!---------------Bottom : STR----------->
		<div id="popup_350se_bottom">
			<s:submit type="image" src="/images/pop_btn_close.gif"
				onclick="window.close(); return false;" />
		</div>
		<!---------------Bottom : END----------->
	</s:form>
</body>
</html>